home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / rexx / imc / rexx-imc.5 / box next >
Encoding:
Text File  |  1993-06-25  |  1.7 KB  |  37 lines

  1. dir=/mclab/imc/`/bin/arch`/;exec ${dir}rexx -x $0 ${dir} $*
  2. parse arg dir args
  3. if args="" then args="/usr/games/fortune"/* default command */
  4. args "| /usr/ucb/expand |" dir"rxstack"  /* stack the command's output */
  5. if rc<>0 then exit rc                /* exit on error */
  6. l=0                                  /* zero maximum length */
  7. s=1e9                                /* minimum space on left */
  8. do i=1 for queued()                  /* pull each line */
  9.    parse pull line.i
  10.    line.i=strip(translate(line.i,,xrange('00'x,'1f'x)||xrange('7f'x)),'T')
  11.                                      /* translate all characters outside the
  12.                                         range 0x20 - 0x7e into spaces.
  13.                                         Remove trailing spaces. */
  14.    l1=length(line.i)
  15.    l2=spc(line.i)
  16.    if l<l1 then l=l1                 /* keep maximum length */
  17.    if s>l2 then s=l2                 /* keep minimum left space */
  18. end
  19. if s=1e9 then s=0                    /* just in case no output */
  20. l=l-s
  21. lines=copies("_",l+4)                /* top and bottom */
  22. cent=33-l%2                          /* in order to be trendy like */
  23. if cent<1 then cent=""               /* everyone else, calculate */
  24. else cent=copies(" ",cent)           /* number of spaces before
  25.                                         each line */
  26. say cent lines                       /* output top */
  27. say cent"|"copies(" ",l+4)"|"        /* output a blank line */
  28. do j=1 to i-1
  29.    say cent"|  "substr(line.j,s+1,l+2)"|"/* output each line of text */
  30. end
  31. say cent"|"lines"|"                  /* output bottom */
  32. return
  33. spc: /* return the number of spaces on the left */
  34. parse arg t
  35. if t='' then return 0
  36. else return verify(t,' ')-1
  37.